import Cookies from 'js-cookie'

const TokenKey = 'X_USER_TOKEN'
const wxUserinfoKey = "wxuse"

export function getToken() {
  // console.log('getToken', Cookies.get(TokenKey))
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  let seconds = 31536000;
  // let seconds = 10;
  let expires = new Date(new Date() * 1 + seconds * 1000);
  return Cookies.set(TokenKey, token, {expires})
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function getWxUserinfoCookies() {
  return Cookies.get(wxUserinfoKey)
}

export function setWxUserinfoCookies(wxuse) {
  let seconds = 31536000;
  // let seconds = 10;
  let expires = new Date(new Date() * 1 + seconds * 1000);
  return Cookies.set(wxUserinfoKey, wxuse, {expires})
}

export function removeWxUserinfoCookies() {
  return Cookies.remove(wxUserinfoKey)
}
